﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JAMR.Rendering.Blocks
{
    public class BlockStore
    {
        // Singleton
        private static BlockStore _instance = new BlockStore();

        public static BlockStore Instance { get { return _instance; } }
 
        // Class
        private BlockStore() 
        {
            // Default fallback
            FallBack = new Air();
        }

        private IDictionary<int, RenderableBlock> _store = new Dictionary<int, RenderableBlock>();

        public RenderableBlock FallBack { get; set; }

        public RenderableBlock GetById(int id)
        {
            if (_store.ContainsKey(id))
                return _store[id];

            return FallBack;
        }
        public void SetById(int id, RenderableBlock block)
        {
            _store[id] = block;
        }
    }
}
